#include <cstdio>

int q[ 2000011 ], head, tail;
int n, sum[ 2000011 ], a[ 1000011 ];

void init( )
{
    int i;
    for ( i = 1; i <= n; i++ )
        scanf("%d", &a[ i ]);
    sum[ 0 ] = 0;
    for ( i = 1; i <= n; i++ )
        sum[ i ] = sum[ i - 1 ] + a[ i ];
    for ( i = n + 1; i < n * 2; i++ )
        sum[ i ] = sum[ i - 1 ] + a[ i - n ];
}

void work( )
{
    int i, cnt = 0;
    head = 0; tail = -1;
    for ( i = 0; i < n; i++ )
    {
        while ( head <= tail && sum[ q[ tail ] ] > sum[ i ] ) tail--;
        q[ ++tail ] = i;
    }
    for ( i = n; i < n * 2; i++ )
    {
        while ( head <= tail && q[ head ] <= i - n ) head++;
        while ( head <= tail && sum[ q[ tail ] ] > sum[ i ] ) tail--;
        q[ ++tail ] = i;
        if ( sum[ q[ head ] ] >= sum[ i - n ] ) cnt++;
    }
    printf("%d\n", cnt);
}

int main( )
{
    while ( scanf("%d", &n) && n )
    {
        init( );
        work( );
    }
    return 0;
}
